package com.authine.cloudpivot.ext.model.order;

import com.authine.cloudpivot.ext.enums.order.OrderCustomerStatusEnum;
import com.authine.cloudpivot.ext.enums.order.OrderTypeEnum;
import com.authine.cloudpivot.ext.enums.order.PaymentMethodEnum;
import com.authine.mvp.app.launcher.domain.SelectorFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Author: liwei
 * @DateTime: 2021/9/17
 * @Description: TODO OrderSimple创建订单
 */
@Data
@Schema(description = "OrderCustomerVO")
@ApiModel("客户订单VO")
public class OrderCustomerVO {

    @ApiModelProperty(value = "id")
    private String id;

    @ApiModelProperty(value = "创建人")
    private String createdBy;

    @ApiModelProperty(value = "创建人部门")
    private String createdDept;

    @ApiModelProperty(value = "创建时间")
    private Date createdTime;

    @ApiModelProperty(value = "修改人")
    private String modifiedBy;

    @ApiModelProperty(value = "修改时间")
    private Date modifiedTime;

    @ApiModelProperty(value = "付款方式")
    private PaymentMethodEnum payment_method;

    @ApiModelProperty(value = "下单时间（下单付款的时间）")
    private String place_order_time;
    @ApiModelProperty(value = "ERP PO")
    private String erp_po;
    @ApiModelProperty(value = "收货人")
    private String receiver;
    @ApiModelProperty(value = "电话")
    private String phone;
    @ApiModelProperty(value = "邮编")
    private String postal;
    @ApiModelProperty(value = "详细地址")
    private String address;

    @ApiModelProperty(value = "运费")
    private BigDecimal freight;
    @ApiModelProperty(value = "税前商品合计")
    private BigDecimal pretax_total;
    @ApiModelProperty(value = "税后商品合计")
    private BigDecimal total;
    @ApiModelProperty(value = "税后商品运费共计")
    private BigDecimal amount;
    @ApiModelProperty(value = "vmi消耗单ids")
    private String vmi_ids;

    @ApiModelProperty(value = "下单人用户ID")
    private SelectorFormat place_order_user_id;
    @ApiModelProperty(value = "下单人名称")
    private String place_order_fullname;
    @ApiModelProperty(value = "客户组织id")
    private SelectorFormat organization_id;
    @ApiModelProperty(value = "客户组织名称")
    private String organization_name;
    @ApiModelProperty(value = "外部来源客户id")
    private String client_id;
    @ApiModelProperty(value = "外部来源用户id")
    private String client_user_id;
    @ApiModelProperty(value = "外部来源订单id")
    private String client_order_id;

    @ApiModelProperty(value = "扩展属性（{\"OS订单号\":\"\",\"实际下单人\":\"\"}）")
    private String extends_attr;
    @ApiModelProperty(value = "是否已启用（true=启用、false=未启用）")
    private Boolean enabled;
    @ApiModelProperty(value = "售后状态（未售后、售后中、已售后）")
    private String after_sale;
    @ApiModelProperty(value = "订单类型（平台订单、外部订单、商城订单、代购订单、VMI订单）")
    private OrderTypeEnum type;
    @ApiModelProperty(value = "未税运费")
    private BigDecimal pretax_freight;
    @ApiModelProperty(value = "税前商品运费共计")
    private BigDecimal pretax_amount;

    @ApiModelProperty(value = "'税额'")
    private BigDecimal tax_payable;
    @ApiModelProperty(value = "审批任务状态")
    private Integer task_ver;
    @ApiModelProperty(value = "可接受最迟交货日")
    private Date accept_delivery_time;
    @ApiModelProperty(value = "version")
    private Integer version;
    @ApiModelProperty(value = "老状态")
    private Integer old_status;
    @ApiModelProperty(value = "订单类型")
    private String source;
    @ApiModelProperty(value = "客户订单状态")
    private OrderCustomerStatusEnum order_customer_status;
    @ApiModelProperty(value = "审批人")
    private String approval_by;
    @ApiModelProperty(value = "'审批意见")
    private String approval_opinion;
    @ApiModelProperty(value = "外部来源客户(第三方下单人)")
    private String client_user;
    @ApiModelProperty(value = "实际下单人")
    private String actual_order;
    @ApiModelProperty(value = "运费税额")
    private BigDecimal tax_payable_freight;

    @ApiModelProperty(value = "客户订单商品集合")
    private List<OrderCustomerGoodsVO> orderCustomerGoodsVOList;

    @ApiModelProperty(value = "供应商订单商品集合")
    private List<OrderVendorGoodsVO> orderVendorGoodsVOList;

    @ApiModelProperty(value = "供应商订单集合")
    private List<OrderVendorVO> orderVendorVOList;


    public static Map<String, Object> transferMap(OrderCustomerVO orderCustomerVOBuild) {

        Map<String, Object> customerMap = new HashMap<>();

        customerMap.put("payment_method",orderCustomerVOBuild.getPayment_method());
        customerMap.put("place_order_time",orderCustomerVOBuild.getPlace_order_time());
        customerMap.put("erp_po",orderCustomerVOBuild.getErp_po());
        customerMap.put("receiver",orderCustomerVOBuild.getReceiver());
        customerMap.put("phone",orderCustomerVOBuild.getPhone());
        customerMap.put("postal",orderCustomerVOBuild.getPostal());
        customerMap.put("address",orderCustomerVOBuild.getAddress());
        customerMap.put("freight",orderCustomerVOBuild.getFreight());
        customerMap.put("pretax_total",orderCustomerVOBuild.getPretax_total());
        customerMap.put("total",orderCustomerVOBuild.getTotal());
        customerMap.put("amount",orderCustomerVOBuild.getAmount());
        customerMap.put("vmi_ids",orderCustomerVOBuild.getVmi_ids());
        customerMap.put("place_order_user_id",orderCustomerVOBuild.getPlace_order_user_id());
        customerMap.put("place_order_fullname",orderCustomerVOBuild.getPlace_order_fullname());
        customerMap.put("organization_id",orderCustomerVOBuild.getOrganization_id());
        customerMap.put("organization_name",orderCustomerVOBuild.getOrganization_name());
        customerMap.put("client_id",orderCustomerVOBuild.getClient_id());
        customerMap.put("client_user_id",orderCustomerVOBuild.getClient_user_id());
        customerMap.put("client_order_id",orderCustomerVOBuild.getClient_order_id());
        customerMap.put("extends_attr",orderCustomerVOBuild.getExtends_attr());
        customerMap.put("enabled",orderCustomerVOBuild.getEnabled());
        customerMap.put("after_sale",orderCustomerVOBuild.getAfter_sale());
        customerMap.put("type",orderCustomerVOBuild.getType());
        customerMap.put("pretax_freight",orderCustomerVOBuild.getPretax_freight());
        customerMap.put("pretax_amount",orderCustomerVOBuild.getPretax_amount());
        customerMap.put("tax_payable",orderCustomerVOBuild.getTax_payable());
        customerMap.put("task_ver",orderCustomerVOBuild.getTask_ver());
        customerMap.put("accept_delivery_time",orderCustomerVOBuild.getAccept_delivery_time());
        customerMap.put("version",orderCustomerVOBuild.getVersion());
        customerMap.put("old_status",orderCustomerVOBuild.getOld_status());
        customerMap.put("source",orderCustomerVOBuild.getSource());
        customerMap.put("order_customer_status",orderCustomerVOBuild.getOrder_customer_status());
        customerMap.put("approval_by",orderCustomerVOBuild.getApproval_by());
        customerMap.put("approval_opinion",orderCustomerVOBuild.getApproval_opinion());
        customerMap.put("client_user",orderCustomerVOBuild.getClient_user());
        customerMap.put("actual_order",orderCustomerVOBuild.getActual_order());
        customerMap.put("tax_payable_freight",orderCustomerVOBuild.getTax_payable_freight());

        return customerMap;
    }
}
